package io.renren;

import org.apache.shiro.crypto.hash.Sha256Hash;

import java.util.Random;

public class RandomString {
    public static String getRandomString(int length) { //length表示生成字符串的长度
        String base = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }
        return sb.toString();
    }
    public static void main(String[]args){
        String str = "1";
        String salt = "XsSbhvB80bvhgv27ykje";
        Sha256Hash sha1 = new Sha256Hash(str, salt);
//        for(int i=0;i<100;i++){
//            System.out.println(getRandomString(20));
//        }
        System.out.println(sha1.toString());
        System.out.println(sha1.toHex());

    }
    public static void test(){
        int count=0;
        double distance=0,height=100;
        while(height>0.000001){
            count++;
            distance+=height*1.5;
            height/=2;
        }
        System.out.println(count);
        System.out.println(distance);
    }
}
